﻿using ApplicationBase.Core.Domain;
using ApplicationBase.Core.Extensions;

namespace IdentityService.Domain.Aggregates.UserAccountAggregate
{
    public class UserInfo : Entity
    {
        public long UserAccountId { get; init; }
        public string? FirstName { get; private set; }
        public string? LastName { get; private set; }
        public string? NickName { get; private set; }

        public UserInfo(long userAccountId)
        {
            UserAccountId = userAccountId;
        }

        public void Modify(string fitstName, string lastName, string nickName)
            => (FirstName, LastName, NickName) = (fitstName, lastName, nickName);

        public string GetFullName()
        {
            if (string.IsNullOrEmpty(FirstName) && string.IsNullOrEmpty(LastName))
                return string.Empty;
            else if (string.IsNullOrEmpty(FirstName))
                return LastName!;
            else if( string.IsNullOrEmpty(LastName)) 
                return FirstName!;
            else
            {
                if (FirstName.HasChineseChar() || LastName.HasChineseChar())
                    return $"{LastName}{FirstName}";
                else
                    return $"{FirstName} {LastName}";
            }
        }
    }
}
